//
//  NSString+String.m
//  socketIO
//
//  Created by zhao on 8/2/16.
//  Copyright © 2016 le. All rights reserved.
//

#import "NSString+String.h"

@implementation NSString (String)

- (NSString *)urlEncode {
  NSCharacterSet *set = [NSCharacterSet characterSetWithCharactersInString:@"!*'();:@&=+$,/?%#[]\" {}"].invertedSet;
  return [self stringByAddingPercentEncodingWithAllowedCharacters:set];
}

- (BOOL) isEqualToStrings:(NSArray *)strings {
  for (NSString *string in strings) {
    if ([self isEqualToString:string]) {
      return YES;
    }
  }
  return NO;
}

- (NSInteger) convert2Int {
  const char *a = self.UTF8String;
  if (a[0] >= 48 && a[0] <= 57) {
    return [self integerValue];
  } else {
    return -1;
  }
}

@end
